package com.ruoyi.system.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.OrderContrastBusinessDetail;
import com.ruoyi.system.service.IOrderContrastBusinessDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 返佣商户比例明细Controller
 *
 * @author hjf
 * @date 2025-06-06
 */
@RestController
@RequestMapping("/hmk/contrastBusinessDetail")
public class OrderContrastBusinessDetailController extends BaseController {
    @Autowired
    private IOrderContrastBusinessDetailService orderContrastBusinessDetailService;

    /**
     * 查询返佣商户比例明细列表
     */
    @PreAuthorize("@ss.hasPermi('hmk:contrastBusinessDetail:list')")
    @GetMapping("/list")
    public TableDataInfo list(OrderContrastBusinessDetail orderContrastBusinessDetail) {
        startPage();
        List<OrderContrastBusinessDetail> list = orderContrastBusinessDetailService.selectOrderContrastBusinessDetailList(orderContrastBusinessDetail);
        return getDataTable(list);
    }

    /**
     * 导出返佣商户比例明细列表
     */
    @PreAuthorize("@ss.hasPermi('hmk:contrastBusinessDetail:export')")
    //@Log(title = "返佣商户比例明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OrderContrastBusinessDetail orderContrastBusinessDetail) {
        List<OrderContrastBusinessDetail> list = orderContrastBusinessDetailService.selectOrderContrastBusinessDetailList(orderContrastBusinessDetail);
        ExcelUtil<OrderContrastBusinessDetail> util = new ExcelUtil<OrderContrastBusinessDetail>(OrderContrastBusinessDetail.class);
        util.exportExcel(response, list, "返佣商户比例明细数据");
    }

    /**
     * 获取返佣商户比例明细详细信息
     */
    @PreAuthorize("@ss.hasPermi('hmk:contrastBusinessDetail:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(orderContrastBusinessDetailService.selectOrderContrastBusinessDetailById(id));
    }

    /**
     * 新增返佣商户比例明细
     */
    @PreAuthorize("@ss.hasPermi('hmk:contrastBusinessDetail:add')")
    //@Log(title = "返佣商户比例明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OrderContrastBusinessDetail orderContrastBusinessDetail) {
        return toAjax(orderContrastBusinessDetailService.insertOrderContrastBusinessDetail(orderContrastBusinessDetail));
    }

    /**
     * 修改返佣商户比例明细
     */
    @PreAuthorize("@ss.hasPermi('hmk:contrastBusinessDetail:edit')")
    //@Log(title = "返佣商户比例明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OrderContrastBusinessDetail orderContrastBusinessDetail) {
        return toAjax(orderContrastBusinessDetailService.updateOrderContrastBusinessDetail(orderContrastBusinessDetail));
    }

    /**
     * 删除返佣商户比例明细
     */
    @PreAuthorize("@ss.hasPermi('hmk:contrastBusinessDetail:remove')")
    //@Log(title = "返佣商户比例明细", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(orderContrastBusinessDetailService.deleteOrderContrastBusinessDetailByIds(ids));
    }
}
